﻿@{
    ViewBag.Title = "CarLockEidt";
}

@using YouWei.Infrastructure.Entity;
@model CarLock
@{
    ViewBag.Title = "地锁信息编辑";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<section class="content">
    <div class="row">
        <div class="col-md-12">
            <form id="editForm" class="form ">

                <div class="form-group">
                    <label>地锁编号</label>
                    <input type="text" class="form-control" name="LockNum" id="LockNum" value="@Model.LockNum" />
                </div>
                <div class="form-group">
                    <label>用户</label>
                    <input type="text" readonly="readonly" class="form-control" value="@ViewBag.UserName" />
                </div>
                <div class="form-group">
                    <label>手机号</label>
                    <input type="text" readonly="readonly" class="form-control" value="@ViewBag.UserMobile" />
                </div>
                <div class="form-group">
                    <label>状态</label>
                    @if (Model.LockStatus == 0)
                    {
                        <input type="text" readonly="readonly" class="form-control" value="降锁" />
                    }
                    else
                    {
                        <input type="text" readonly="readonly" class="form-control" value="升锁" />
                    }
                </div>
                <div data-toggle="distpicker" class="form-group">
                    <label>所在地</label>
                    <div>
                        <select style="width: 20%; display: inline-block;" name="ProvinceID" id="HProvinceID" class="form-control"></select>
                        <select style="width: 20%; display: inline-block;" name="CityID" id="HCityID" class="form-control"></select>
                        <select style="width: 20%; display: inline-block;" name="DistrictID" id="HDistrictID" class="form-control"></select>
                    </div>
                </div>

                <div class="form-group">
                    <label>地址</label>
                    <input type="text" class="form-control" name="Address" id="Address" value="@Model.Address" />
                </div>
                <div class="form-group">
                    <label>详细位置</label>
                    <input type="text" class="form-control" name="Parking" id="Parking" value="@Model.Parking" />
                </div>
                <div class="form-group">
                    <button type="button" class="btn btn-success btn-sm" id="btnSave">保存</button>
                </div>
            </form>
        </div>
    </div>
</section>
@section scriptsBottom{
    <script type="text/javascript">
        $(document).ready(function () {
            //分类
            var id = @Model.ID;
            $("#btnSave").on("click", function () {
                save();
            });

            var pid = "@Model.ProvinceID";
            var cid = "@Model.CityID";
            var did = "@Model.DistrictID";
            $("#HProvinceID").val(pid);
            $("#HProvinceID").change();
            $("#HCityID").val(cid);
            $("#HCityID").change();
            $("#HDistrictID").val(did);
        });
        //保存
        function save() {
            var fdata = $("#editForm").serializeJson();
                var id = "@Model.ID";
                BMCW.ajax({
                    url: "@Url.Action("CarLockSave", "CarLock")?id=" + id,
                    type: "POST",
                    data: fdata,
                    dataType: "json",
                        success: function (data) {
                            if (data.status == 0) {
                                BMCW.alert(data.message);
                                setTimeout(function () {
                                    window.location.reload();
                                }, 2000);
                            } else {
                                BMCW.alert(data.message);
                            }
                        }
                    });
        }
    </script>
}